﻿
package system.data;

import java.util.*;

import framework.core.*;
/*
	Author    :Jackey
	CreateTime:2008-03-03 10:38:35
*/
public class MenuInfoBase extends Table 
{
public static final String TABLE_NAME = "T_MENU_INFO";

private static final String BACKUP_TABLE_NAME = "T_MENU_INFO_BACKUP";

private static final String BACKUP_SEQ_NAME = "S_MENU_INFO_BACKUP";


public static final String ID = "ID";

public static final String MENU_CODE = "MENU_CODE";

public static final String MENU_NAME = "MENU_NAME";

public static final String URL = "URL";

public static final String DISPLAY_ORDER = "DISPLAY_ORDER";

public static final String SHOW_TYPE = "SHOW_TYPE";

public static final String PARENT_CODE = "PARENT_CODE";


public static Vector m_fields = null;


private String m_id = ""; //ID

private int m_menu_code = Value.NULL_INT;  //菜单编码

private String m_menu_name = ""; //菜单名称

private String m_url = ""; //菜单页面地址

private int m_display_order = Value.NULL_INT;  //显示顺序

private String m_show_type = ""; //显示类型

private int m_parent_code = Value.NULL_INT;  //父级菜单



	public String getId()
	{
	    return m_id;
	}
	public void  setId(String v)
	{
		if(getId().equals(v)) return ;
		m_id = v ;
		markDirty(ID);
	}



	

	public int getMenuCode()
	{
	    return m_menu_code;
	}
	public void  setMenuCode(int v)
	{
		if(getMenuCode()==v) return ;
		m_menu_code = v ;
		markDirty(MENU_CODE);
	}



	

	public String getMenuName()
	{
	    return m_menu_name;
	}
	public void  setMenuName(String v)
	{
		if(getMenuName().equals(v)) return ;
		m_menu_name = v ;
		markDirty(MENU_NAME);
	}



	

	public String getUrl()
	{
	    return m_url;
	}
	public void  setUrl(String v)
	{
		if(getUrl().equals(v)) return ;
		m_url = v ;
		markDirty(URL);
	}



	

	public int getDisplayOrder()
	{
	    return m_display_order;
	}
	public void  setDisplayOrder(int v)
	{
		if(getDisplayOrder()==v) return ;
		m_display_order = v ;
		markDirty(DISPLAY_ORDER);
	}



	

	public String getShowType()
	{
	    return m_show_type;
	}
	public void  setShowType(String v)
	{
		if(getShowType().equals(v)) return ;
		m_show_type = v ;
		markDirty(SHOW_TYPE);
	}



	

	public int getParentCode()
	{
	    return m_parent_code;
	}
	public void  setParentCode(int v)
	{
		if(getParentCode()==v) return ;
		m_parent_code = v ;
		markDirty(PARENT_CODE);
	}



	



	public String viewId(DBConnection con) throws Exception
	{
		return Value.view(getId());
	}

	public String viewMenuCode(DBConnection con) throws Exception
	{
		return Value.view(getMenuCode());
	}

	public String viewMenuName(DBConnection con) throws Exception
	{
		return Value.view(getMenuName());
	}

	public String viewUrl(DBConnection con) throws Exception
	{
		return Value.view(getUrl());
	}

	public String viewDisplayOrder(DBConnection con) throws Exception
	{
		return Value.view(getDisplayOrder());
	}

	public String viewShowType(DBConnection con) throws Exception
	{
		return Value.view(getShowType());
	}

	public String viewParentCode(DBConnection con) throws Exception
	{
		return Value.view(getParentCode());
	}



protected MenuInfoBase()
{
}

public void fill(MenuInfoPageData pageData) throws Exception
{

	if(pageData.getId()!=null)
	{	
		setId(pageData.getId());
	}

	if( pageData.getMenuCode()!=null && 
	   !pageData.getMenuCode().equals(""))
	{	
		setMenuCode(Integer.parseInt(pageData.getMenuCode()));
	}

	if(pageData.getMenuName()!=null)
	{	
		setMenuName(pageData.getMenuName());
	}

	if(pageData.getUrl()!=null)
	{	
		setUrl(pageData.getUrl());
	}

	if( pageData.getDisplayOrder()!=null && 
	   !pageData.getDisplayOrder().equals(""))
	{	
		setDisplayOrder(Integer.parseInt(pageData.getDisplayOrder()));
	}

	if(pageData.getShowType()!=null)
	{	
		setShowType(pageData.getShowType());
	}

	if( pageData.getParentCode()!=null && 
	   !pageData.getParentCode().equals(""))
	{	
		setParentCode(Integer.parseInt(pageData.getParentCode()));
	}

}

public String getTableName() 
{
	return TABLE_NAME;
}

public String getBackupTableName() 
{
	return BACKUP_TABLE_NAME;
}

public String getBackupSeqName() 
{
	return BACKUP_SEQ_NAME;
}

public java.util.Vector getFields() 
{
	if(m_fields==null)
	{
		m_fields = new Vector();

		m_fields.add(new Field(ID,Value.TYPE_STRING,true,true,32,"ID"));

		m_fields.add(new Field(MENU_CODE,Value.TYPE_INT,false,true,0,"菜单编码"));

		m_fields.add(new Field(MENU_NAME,Value.TYPE_STRING,false,true,100,"菜单名称"));

		m_fields.add(new Field(URL,Value.TYPE_STRING,false,true,200,"菜单页面地址"));

		m_fields.add(new Field(DISPLAY_ORDER,Value.TYPE_INT,false,false,0,"显示顺序"));

		m_fields.add(new Field(SHOW_TYPE,Value.TYPE_STRING,false,false,50,"显示类型"));

		m_fields.add(new Field(PARENT_CODE,Value.TYPE_INT,false,false,0,"父级菜单"));
		
	}
	return m_fields;
}

public void initObject(java.sql.ResultSet rs) throws Exception
{

	m_id = getString(rs,ID);

	m_menu_code = getInt(rs,MENU_CODE);

	m_menu_name = getString(rs,MENU_NAME);

	m_url = getString(rs,URL);

	m_display_order = getInt(rs,DISPLAY_ORDER);

	m_show_type = getString(rs,SHOW_TYPE);

	m_parent_code = getInt(rs,PARENT_CODE);

	ms_new_flag = ConstDefine.NO;
}

public Value get(String f)
{

	if(f.equalsIgnoreCase(ID))
	{
		return new Value(getId());
	}

	if(f.equalsIgnoreCase(MENU_CODE))
	{
		return new Value(getMenuCode());
	}

	if(f.equalsIgnoreCase(MENU_NAME))
	{
		return new Value(getMenuName());
	}

	if(f.equalsIgnoreCase(URL))
	{
		return new Value(getUrl());
	}

	if(f.equalsIgnoreCase(DISPLAY_ORDER))
	{
		return new Value(getDisplayOrder());
	}

	if(f.equalsIgnoreCase(SHOW_TYPE))
	{
		return new Value(getShowType());
	}

	if(f.equalsIgnoreCase(PARENT_CODE))
	{
		return new Value(getParentCode());
	}
	
	return null;
}
public void set(String f,Value v) throws Exception
{

	if(f.equalsIgnoreCase(ID))
	{
		setId(v.getString());
	}

	if(f.equalsIgnoreCase(MENU_CODE))
	{
		setMenuCode(v.getInt());
	}

	if(f.equalsIgnoreCase(MENU_NAME))
	{
		setMenuName(v.getString());
	}

	if(f.equalsIgnoreCase(URL))
	{
		setUrl(v.getString());
	}

	if(f.equalsIgnoreCase(DISPLAY_ORDER))
	{
		setDisplayOrder(v.getInt());
	}

	if(f.equalsIgnoreCase(SHOW_TYPE))
	{
		setShowType(v.getString());
	}

	if(f.equalsIgnoreCase(PARENT_CODE))
	{
		setParentCode(v.getInt());
	}
	
}
public String toString()
{
	String msg = "MenuInfo=\n";
	msg += "(\r\n";

	msg += "    ID(id)="+get("id")+"\r\n";

	msg += "    菜单编码(menu_code)="+get("menu_code")+"\r\n";

	msg += "    菜单名称(menu_name)="+get("menu_name")+"\r\n";

	msg += "    菜单页面地址(url)="+get("url")+"\r\n";

	msg += "    显示顺序(display_order)="+get("display_order")+"\r\n";

	msg += "    显示类型(show_type)="+get("show_type")+"\r\n";

	msg += "    父级菜单(parent_code)="+get("parent_code")+"\r\n";
		
	msg += ")\r\n";
	return msg;
}
public void copyBase(MenuInfoBase srcObj)
{

	setMenuCode(srcObj.getMenuCode());

	setMenuName(srcObj.getMenuName());

	setUrl(srcObj.getUrl());

	setDisplayOrder(srcObj.getDisplayOrder());

	setShowType(srcObj.getShowType());

	setParentCode(srcObj.getParentCode());

}

public String toXml() throws Exception
{
	String xml = "";
	xml += "<MenuInfo>";

	xml += "<Id>"+Value.view(getId())+"</Id>";

	xml += "<MenuCode>"+Value.view(getMenuCode())+"</MenuCode>";

	xml += "<MenuName>"+Value.view(getMenuName())+"</MenuName>";

	xml += "<Url>"+Value.view(getUrl())+"</Url>";

	xml += "<DisplayOrder>"+Value.view(getDisplayOrder())+"</DisplayOrder>";

	xml += "<ShowType>"+Value.view(getShowType())+"</ShowType>";

	xml += "<ParentCode>"+Value.view(getParentCode())+"</ParentCode>";
	
	xml += "</MenuInfo>";
	return xml;
}

}
